﻿using System.ComponentModel;
using System.Web.Mvc;
using Lyh.Core.Result;
using Lyh.Facade;
using Lyh.Models;
using Lyh.Models.Ext;

namespace Lyh.Controllers
{
    public class ActionController : BaseController
    {
        private readonly IActionFacade actionFacade;

        public ActionController(IActionFacade actionFacade)
        {
            this.actionFacade = actionFacade;
        }

        public ActionResult Action()
        {
            return View();
        }

        public ActionResult SaveOrUpdate(Models.Action model)
        {
            actionFacade.SaveOrUpdate(model);
            var result = new ExtResult
            {
                Success = true,
                Message = "成功",
                Title = "结果"
            };

            return this.CustomJson(result);
        }

        [Description("获取功能编辑时的下拉框数据")]
        public ActionResult ComboSource()
        {
            var s = actionFacade.GetAllActionByAssembly();
            var data = new ExtGridData<Action> {Items = s, total = 35,pageSize=3};
            return this.CustomJson(data);
        }
    }
}
